﻿using QYmall.Core.IServices;
using Quartz;

namespace QYmall.Core.API.Quartz
{
    /// <summary>
    /// 订单定时任务(防并发)
    /// </summary>
    [DisallowConcurrentExecution]
    public class OrderSettleJobs : IJob
    {
        private readonly ILogger<OrderSettleJobs> _logger;
        private readonly IOrderService _orderService;

        /// <summary>
        /// 依赖注入
        /// </summary>
        public OrderSettleJobs(ILogger<OrderSettleJobs> logger, IOrderService orderService)
        {
            _logger = logger;
            _orderService = orderService;
        }

        /// <summary>
        /// 执行任务
        /// </summary>
        public async Task Execute(IJobExecutionContext context)
        {
            await _orderService.JobSettleAsync();
        }
    }
}
